<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>市场专员列表</title>
		<link rel="stylesheet" href="__AGENT__/css/iconfont.css" />
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script src="__PUBLIC__/static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		{include file="public/header" /}
		<div class="index_conbox">
			<div class="index_content clearfix">
				{include file="public/lefter" /}
				<div class="right">
					<!--右侧内容-->
					<div class="rigtop">
						<span class="title" style="float:left;">市场专员</span>
						<span><div class="chax_jiegbt clearfix">
								{if $Think.session.user_level ==3 && $list->total()<20}
								<div class="chax_xzbtnbox">
									<button class="zizh_btn" type="button" onclick="pt_add()"><i class="iconfont icon-jia"></i>增加市场专员</button>
								</div>
								{/if}
						</div>
					</span>
					</div>
					<div class="indrig_con" style="position: relative;">
						<div class="zizh_conbox" style="padding-top: 20px;">
							<!--选项卡内容开始-->
							{if $Think.session.user_level==1 || $Think.session.user_level==2 || $Think.session.user_level==4 || $Think.session.user_level==3}
							<form id="my_form" action="{:url('oem/accounts/pt_user')}" method="post">
								<div class="zizh_con_1">
									<div class="shxx_row chax_row  clearfix">
										{if $Think.session.user_level==1}
											<div class="left">省级代理：</div>
											<div class="right clearfix">
												<div id="htselect">
													<select name="agency_id" id="agency_id">
														<option value="">全部</option>
														{volist name="province" id="str"}
														<option {if $agency_id==$str.id} selected {/if} value="{$str.id}">{$str.user_name}</option>
														{/volist}
													</select>
												</div>
											</div>
											{/if}
											{if $Think.session.user_level==1 || $Think.session.user_level==4}
											<div class="left"  style="margin-left: 10px;">市级代理：</div>
											<div class="right clearfix">
												<div id="htselect">
													<select name="agency_id1" id="agency_id1">
														<option value="">全部</option>
														{volist name="agency" id="vo"}
														<option {if $agency_id1==$vo.id} selected {/if} value="{$vo.id}">{$vo.user_name}</option>
														{/volist}
													</select>
												</div>
											</div>
										{/if}
										{if $Think.session.user_level==1 || $Think.session.user_level==4}
											<div class="left" style="margin-left: 10px;">运营商ID：</div>
											<div class="right clearfix">
												<input type="text" name="agency_id2" placeholder="请输入运营商ID" class="chax_input" value="{$agency_id2}"/>
											</div>
										{/if}
										{if $Think.session.user_level==2}
											<div class="left"  style="margin-left: 10px;">运营商：</div>
											<div class="right clearfix">
												<div id="htselect">
													<select name="agency_id2" id="agency_id2">
															<option value="">全部</option>
															{volist name="area" id="ts"}
															<option {if $agency_id2==$ts.id} selected {/if} value="{$ts.id}">{$ts.user_name}</option>
															{/volist}
													</select>
												</div>
											</div>
										{/if}
										<div class="left">手机号：</div>
										<div class="right clearfix">
											<input type="text" name="mobile" value="{$mobile}" id="mobile" placeholder="手机号码" class="chax_input" />
										</div>
										<button type="submit" class="htcxbtn">查询</button>
									</div>
								</id>
							</form>
							{/if}
							<div class="zizh_con_1">
									<div class="chax_conbox">
										<div class="chax_jieg">总计：{$list->total();}</div>
										<div class="chax_jiegnr">
											<table class="zizh_table1">
												<thead>
													<tr style="text-align: center;">
														<th class="w_10">ID</th>
														<th class="w_10">姓名</th>
														<th class="w_10">手机号</th>
														{if $Think.session.user_level==1 ||  $Think.session.user_level==4 }
														<th class="w_10">市代理商</th>
														{/if}
														{if $Think.session.user_level==1 ||  $Think.session.user_level==4 || $Think.session.user_level==2}
														<th class="w_10">区域运营商</th>
														{/if}
														<th class="w_10">余额</th>
														<th class="w_10">推广商家数</th>
														<th class="w_10">分佣比例</th>
														<th class="w_10">添加时间</th>
														<th class="w_10">操作</th>
													</tr>
												</thead>
												<tbody id="tbody">
													{volist name="$list" id="vo" }
													<tr style="text-align: center;">
														<td>{$vo.id}</td>
														<td>{$vo.user_name?$vo.user_name:$vo.nickname}</td>
														<td>{$vo.mobile}</td>
														{if $Think.session.user_level==1 ||  $Think.session.user_level==4}
														<td>{$vo.agency_name}</td>
														{/if}
														{if $Think.session.user_level==1 ||  $Think.session.user_level==4 || $Think.session.user_level==2}
														<td>{$vo.city_name}</td>
														{/if}
														<td><a href="javascript:;log_user('{$vo.id}')">{$vo.balance}</a></td>
														<td><a href="{:url('accounts/agent',['cm'=>$vo.mobile])}">
															{$vo.b?$vo.b : 0}
															</a>
														</td>
														<td>
															{$vo.sc_bili}%
														</td>
														<td>{$vo.pt_time|substr=0,10}</td>														
														<td>
															<?php if($vo['b']==0 || empty($vo['b'])){ ?><a onclick="jiechu('{$vo.id}')" style="background:blueviolet;">解除</a><?php } ?>
															<a onclick="pt_edit('{$vo.id}')" class="gray">编辑</a>
															<a href="javascript:;" onclick="pt_count('{$vo.id}')">统计</a>
														</td>
													</tr>
													{/volist}
													{if $list==null||count($list)==0}<tr><td colspan="10" style="text-align: center;">无市场专员信息</td></tr>{/if}
												</tbody>
											</table>
											<div class="fenye" style="display: block;">
												{$list->render()}
											</div>
										</div>
									</div>
							</div>
						</div>

					</div>
				</div>
			</div>
		</div>
		{include file="public/footer" /}

	</body>

</html>
<script>
	layui.use('laydate', function() {
		var laydate = layui.laydate;

		//日期控件
		laydate.render({
			elem: '#begin_time',
			type: 'datetime',
			format: 'yyyy-MM-dd HH:mm:ss'
		});

		laydate.render({
			elem: '#end_time',
			type: 'datetime',
			format: 'yyyy-MM-dd HH:mm:ss'
		});
	})
	function jiechu(id){
				var con = layer.confirm('确认解除资格?', function(index) {
				$.ajax({
					url:"{:url('accounts/jiechu')}",
					data: {
						id: id
					},
					success: function(data) {
						layer.msg(data.msg);
						layer.close(con);
						window.location.reload();
					}
				})
			});
		
	}
	//余额记录
	function log_user(id){
			var show_url = "{:url('accounts/log_user')}"+'?id='+id;
			layer.open({
				type: 2,
				title: '余额记录',
				shadeClose: true,
				shade: 0.8,
				area: ['900px', '730px'],
				content: show_url
			});
	}

	//新增会员
	function pt_add() {
		layer.open({
			type: 2,
			title: '添加市场专员',
			shadeClose: true,
			shade: 0.8,
			area: ['500px', '250px'],
			content: "{:url('accounts/pt_add')}"
		});
	}
	
	function show_member(id){
			
		var show_url = "{:url('accounts/show_ptuser_member')}"+'?id='+id;
		
		layer.open({
			type: 2,
			title: '成员列表',
			shadeClose: true,
			shade: 0.8,
			area: ['775px', '700px'],
			content: show_url
		});
	}
	
	//新增会员
	function pt_edit(id) {
		var show_url = "{:url('accounts/pt_edit')}"+'?id='+id;
		layer.open({
			type: 2,
			title: '编辑市场专员',
			shadeClose: true,
			shade: 0.8,
			area: ['500px', '350px'],
			content: show_url
		});
	}
	
	//统计
	function pt_count(id){
		var show_url = "{:url('accounts/pt_count')}"+'?id='+id;
		layer.open({
			type: 2,
			title: '数据统计',
			shadeClose: true,
			shade: 0.8,
			area: ['900px', '730px'],
			content: show_url
		});
	}
</script>